Powershell新的PSSession访问被拒绝 您所在的位置:网站首页 powershell 远程执行命令 Powershell新的PSSession访问被拒绝

Powershell新的PSSession访问被拒绝

2023-07-18 04:37| 来源: 网络整理| 查看: 265

PS会话用于访问远程系统。为此,您必须执行几项配置:

1)确保winrm服务在所有目标系统以及本地系统中运行。

2)您必须启用PS Remoting。启用-PSRemoting将计算机配置为接收以WS-Man发送的PowerShell远程命令。

因此,启动Windows PowerShell作为管理员

Enable-PSRemoting –Force

3)您需要在远程计算机添加到受信任主机列表中WinRM的本地计算机。要做到这一点,类型:

winrm s winrm/config/client '@{TrustedHosts="RemoteComputer"}'

4)检查使用配置:

winrm quickconfig

完成后,您可以使用新的PSSession命令创建一个交互式会话目的地系统。

否则,您可以使用调用命令像下面执行一些远程操作:

我在评论区它是如何工作的提及。 样品:

$username = "Username" $password = "Password" $secstr = New-Object -TypeName System.Security.SecureString $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)} $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr # will list all the processess in the remote system # if you are the entireprise admin or the domain admin then you do not have to pass the credentials. It will take the windows authentication by default. Invoke-Command -ComputerName RemoteServer -ScriptBlock {Get-Process } -Credential $cred

既然你已经更新了一个问题:让我告诉你一点忠告:

127.0.0.1和本地主机 - 两者都指向到本地系统。意味着您必须将它们添加到本地系统的可信主机列表中。 不建议将PSSession用于本地系统,因为您可以直接在PS控制台中运行所有PS cmdlet。

22.222.222.222 - 和工作,因为你有加,在可信主机列表它默认

22.222.222.222使用Windows身份验证-Credential GET-凭据 - ---不工作,因为格式有点不对。像这样使用:

New-PSSession -ComputerName 22.222.222.222 -Credential (Get-Credential)

希望它可以帮助你。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有